#!/usr/bin/env node

const Koa = require('koa');
const app = new Koa();

app.use((ctx, next) => {
    next();
    const cost = ctx.response.header.cost;
    console.log(`${ctx.mthod} ${ctx.path}  ${cost}ms`);
});

app.use((ctx, next) => {
  //M-ms
  const start = Date.now();
  next();
  const end  = Date.now();
  ctx.set('cost', end-start);
});

app.use((ctx, next) => {
    ctx.body = 'hello world!';
});

app.listen(8080);

console.log('Hello World')
